#include <iostream>
#include <vector>

#include "TestCaseGenerator.h"

using namespace std;

void Swap(int &a, int &b)
{
	int tmp = a;
	a = b;
	b = tmp;
}

void ShellSort(vector<int> &array)
{
	if (array.size() < 2)
		return;

	int length = array.size();
	int gap = length / 2;

	while (gap > 0)
	{
		for (int  i = gap; i < length; i++)
		{
			int pos = i;
			while (pos - gap >= 0 && array[pos - gap] > array[pos])
			{
				Swap(array[pos - gap], array[pos]);
				pos -= gap;
			}
		}
		gap /= 2;
	}
}


int main()
{
	shared_ptr<TestCaseGenerator> tcgPtr;

	vector<int> testCaseArray = tcgPtr->GenerateTestCase(5, 0, 10);
	ShellSort(testCaseArray);

	vector<int> testCaseArray1 = tcgPtr->GenerateTestCase();
	cout << " Before sort: testCaseArray1: " << endl;
	for each (int var in testCaseArray1)
		cout << var << " ";
	cout << endl;

	ShellSort(testCaseArray1);
	cout << " After sort: testCaseArray1: " << endl;
	for each (int var in testCaseArray1)
		cout << var << " ";
	cout << endl;
	

	return 0;
}